﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class blue : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
     protected string[] SSQList = null;
    protected string SSQblue = null;
    protected DataTable dtPaperList = new DataTable();
    protected int jinqiCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    { ZoushiManage.FangWenZouShi();
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }

    protected int[] TiaoxingDT2 = new int[11];
    protected void bindData(int maxValue)
    {

        int Count = 0;
        arlist = BLL.LotteryAnnouncement.GetPageList_Where(0, maxValue, 1, out  Count);

        if (arlist != null)
        {
            dtPaperList.Columns.Add("blue", typeof(string));
            dtPaperList.Columns.Add("bluelast", typeof(string));
            dtPaperList.Columns.Add("dan", typeof(string));
            dtPaperList.Columns.Add("shuang", typeof(string));
            dtPaperList.Columns.Add("xiao", typeof(string));
            dtPaperList.Columns.Add("da", typeof(string));
            dtPaperList.Columns.Add("sanlu1", typeof(string));
            dtPaperList.Columns.Add("sanlu2", typeof(string));
            dtPaperList.Columns.Add("sanlu3", typeof(string));
            dtPaperList.Columns.Add("siqu1", typeof(string));
            dtPaperList.Columns.Add("siqu2", typeof(string));
            dtPaperList.Columns.Add("siqu3", typeof(string));
            dtPaperList.Columns.Add("siqu4", typeof(string));

            for (int i = 0; i < arlist.Count; i++)
            {
                DataRow newRow = dtPaperList.NewRow();
                //重号
                string blueBall = arlist[i].LotteryNo.Split('+')[1]; //蓝球
                string bluelast = blueBall.Substring(blueBall.Length-1,1);//蓝球尾数
                string dan = "";//是否单数
                string shuang = "";//是否双数
                string xiao = "";//是否小数
                string  da = "";//是否大数
                int sanlu1=0;
                int sanlu2=0;
                int sanlu3=0;
                int siqu1=0;
                int siqu2=0;
                int siqu3=0;
                int siqu4 = 0;
                //计算条形图中每个数的个数  

                bindTiaoxing(0, int.Parse(blueBall));
               

                if (int.Parse(blueBall) % 2 == 0)
                {
                    shuang = "双";
                    TiaoxingDT2[1] += 1;
                }
                else
                {
                    dan = "单";
                    TiaoxingDT2[0] += 1;
                }
                if (int.Parse(blueBall) >= 5)
                {
                    da = "大";
                    TiaoxingDT2[3] += 1;
                }
                else if (int.Parse(blueBall) < 5)
                {
                    xiao = "小";
                    TiaoxingDT2[2] += 1;
                }
                if (int.Parse(blueBall) == 0 || int.Parse(blueBall) == 3 || int.Parse(blueBall) == 6)
                {
                    sanlu1 = 1;
                    TiaoxingDT2[4] += 1;
                }
                else if (int.Parse(blueBall) == 1 || int.Parse(blueBall) == 4 || int.Parse(blueBall) == 7)
                {
                    sanlu2 = 1;
                    TiaoxingDT2[5] += 1;
                }
                else if (int.Parse(blueBall) == 2 || int.Parse(blueBall) == 5 || int.Parse(blueBall) == 8)
                {
                    sanlu3 = 1;
                    TiaoxingDT2[6] += 1;
                }
               
                if (int.Parse(blueBall) <= 4 && int.Parse(blueBall) > 0)
                {
                    siqu1 = 1;
                    TiaoxingDT2[7] += 1;
                }
                else if (int.Parse(blueBall) <= 8 && int.Parse(blueBall) > 4)
                {
                    siqu2 = 1;
                    TiaoxingDT2[8] += 1;
                }
                else if (int.Parse(blueBall) <= 12 && int.Parse(blueBall) > 8)
                {
                    siqu3 = 1;
                    TiaoxingDT2[9] += 1;
                }
                else if (int.Parse(blueBall) <= 16 && int.Parse(blueBall) > 12)
                {
                    siqu4 = 1;
                    TiaoxingDT2[10] += 1;
                }
                newRow["blue"] = blueBall;
                newRow["bluelast"] = bluelast;
                newRow["dan"] = dan;
                newRow["shuang"] = shuang;
                newRow["xiao"] = xiao;
                newRow["da"] = da;
                newRow["sanlu1"] = sanlu1;
                newRow["sanlu2"] = sanlu2;
                newRow["sanlu3"] = sanlu3;
                newRow["siqu1"] = siqu1;
                newRow["siqu2"] = siqu2;
                newRow["siqu3"] = siqu3;
                newRow["siqu4"] = siqu4;
                dtPaperList.Rows.Add(newRow);

            }
             
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[26];
    /// <summary>
    /// 计算条形码数值
    /// </summary>
    /// <param name="type">0蓝球号码走势，1蓝球尾数</param>
    /// <param name="data">数字</param>
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 26; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            if (type == 1)
            {
                if ((data + 16 * type) == i)
                {
                    TiaoxingDT[data + 16 * type] += 1;
                }
            }
        }
    }
}